<?php
define('FPDF_FONTPATH','font/');
require_once('fpdf.php');
require_once('gisp_admincon.php');
require_once('qrcode.class.php');
require_once("Connections/coneccionRatania.php");
require_once("Connections/funciones_pg.php");
//include_once('rotation.php');



	
	
class PDF extends FPDF{

var $angle=0;
var $javascript;
var $n_js;

	function IncludeJS($script) {
		$this->javascript=$script;
	}

	function _putjavascript() {
		$this->_newobj();
		$this->n_js=$this->n;
		$this->_out('<<');
		$this->_out('/Names [(EmbeddedJS) '.($this->n+1).' 0 R]');
		$this->_out('>>');
		$this->_out('endobj');
		$this->_newobj();
		$this->_out('<<');
		$this->_out('/S /JavaScript');
		$this->_out('/JS '.$this->_textstring($this->javascript));
		$this->_out('>>');
		$this->_out('endobj');
	}


function AutoPrint($dialog=false)
{
	//Open the print dialog or start printing immediately on the standard printer
	$param=($dialog ? 'true' : 'false');
	$script="print($param);";
	$this->IncludeJS($script);
}

function AutoPrintToPrinter($server, $printer, $dialog=false)
{
	//Print on a shared printer (requires at least Acrobat 6)
	$script = "var pp = getPrintParams();";
	if($dialog)
		$script .= "pp.interactive = pp.constants.interactionLevel.full;";
	else
		$script .= "pp.interactive = pp.constants.interactionLevel.automatic;";
	$script .= "pp.printerName = '\\\\\\\\".$server."\\\\".$printer."';";
	$script .= "print(pp);";
	$this->IncludeJS($script);
}


	function _putresources() {
		parent::_putresources();
		if (!empty($this->javascript)) {
			$this->_putjavascript();
		}
	}

	function _putcatalog() {
		parent::_putcatalog();
		if (!empty($this->javascript)) {
			$this->_out('/Names <</JavaScript '.($this->n_js).' 0 R>>');
		}
	}
	

function Rotate($angle,$x=-1,$y=-1)
{
	if($x==-1)
		$x=$this->x;
	if($y==-1)
		$y=$this->y;
	if($this->angle!=0)
		$this->_out('Q');
	$this->angle=$angle;
	if($angle!=0)
	{
		$angle*=M_PI/180;
		$c=cos($angle);
		$s=sin($angle);
		$cx=$x*$this->k;
		$cy=($this->h-$y)*$this->k;
		$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
	}
}

function _endpage()
{
	if($this->angle!=0)
	{
		$this->angle=0;
		$this->_out('Q');
	}
	parent::_endpage();
}

function RotatedText($x,$y,$txt,$angle)
{
    //Text rotated around its origin
    $this->Rotate($angle,$x,$y);
    $this->Text($x,$y,$txt);
    $this->Rotate(0);
}

function RoundedRect($x, $y, $w, $h, $r, $style = '')
    {
        $k = $this->k;
        $hp = $this->h;
        if($style=='F')
            $op='f';
        elseif($style=='FD' || $style=='DF')
            $op='B';
        else
            $op='S';
        $MyArc = 4/3 * (sqrt(2) - 1);
        $this->_out(sprintf('%.2F %.2F m',($x+$r)*$k,($hp-$y)*$k ));
        $xc = $x+$w-$r ;
        $yc = $y+$r;
        $this->_out(sprintf('%.2F %.2F l', $xc*$k,($hp-$y)*$k ));

        $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc);
        $xc = $x+$w-$r ;
        $yc = $y+$h-$r;
        $this->_out(sprintf('%.2F %.2F l',($x+$w)*$k,($hp-$yc)*$k));
        $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r);
        $xc = $x+$r ;
        $yc = $y+$h-$r;
        $this->_out(sprintf('%.2F %.2F l',$xc*$k,($hp-($y+$h))*$k));
        $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc);
        $xc = $x+$r ;
        $yc = $y+$r;
        $this->_out(sprintf('%.2F %.2F l',($x)*$k,($hp-$yc)*$k ));
        $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r);
        $this->_out($op);
    }

    function _Arc($x1, $y1, $x2, $y2, $x3, $y3)
    {
        $h = $this->h;
        $this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $x1*$this->k, ($h-$y1)*$this->k,
            $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k));
    }
	
	function Header(){
		//datos SQL
		global $login;
		global $centro_costo;
		global $nom_oficina;
		global $cod_actproy;
		global $des_actproy;
		global $cod_nemonico;
		global $des_nemonico;
		global $title;
		global $nro_nec;
		global $ano_eje;
		global $fch_nec;
		global $tipo_bien;
		global $reqs_anuales;			
		global $topIni;
		global $marIni;
		global $wcel;
		global $empresaM;
		global $distrito;
		global $departamento;
		global $provincia;
		global $logoCabIzq;
		global $logoSupP1;
		global $logoSupP2;
		global $logoSupP3;
		global $logoSupP4;
		global $marcaAguaP1;
		global $marcaAguaL1;
		global $marcaAguaL2;
		global $marcaAguaL3;
		global $marcaAguaL4;global $marcaAguaP2;
		global $marcaAguaP3;
		global $marcaAguaP4;
		global $marcaDeAgua;
		global $repositorioFirmas;
		global $RUC;
		global $numero_recibo;
		global $codigoContrib;
		global $nombreContrib;
		global $nroDoc;
		global $direccionContrib;
		global $cajero;
		global $fechaEmision;
		global $fechaImpresion;
		global $fechaProyectado1;
		global $err;
		global $fechaRecargos;
		global $usuario;
		global $colCab;
		global $colSubCab;
		global $tituloHR1;
                global $tituloHR2;
                global $tituloHR3;
                global $tituloHR4;
                global $p_nroDoc;
                global $direcreferencia;
                global $disdirfiscal;
                global $documento;
                global $vusuario; 
                global $fechareg; 
                
		
		
		$lw = $marIni;
		$ln = $topIni;
		$ls = 3;
		$lh = 0;
		//MArca de Agua
		$this->Image('../img/marca/escudomarcaagua4.png',$marcaAguaL1-20,$marcaAguaL2-65,$marcaAguaL3+40,$marcaAguaL4+40,'PNG');
		
		//Logo
		$this->SetFont('narrow','',8);
		//$this->SetFillColor(206,232,212); //verde agua
		$this->SetFillColor(188,217,190); //verde agua
		$this->SetXY($lw-10,$lh);
		$this->Cell(220,6,"",0,1,'L',true);
		$this->SetFillColor(243);
		$this->SetFont('arial','B',9);
		$this->SetXY($lw-10,$lh);
		$this->MultiCell(50,6,'Calle 9 de Junio Nro 100',1,'C');
		$this->SetXY($lw+40,$lh);
		$this->MultiCell(50,6,'Puente Piedra - Lima - Peru',1,'C');
		$this->SetXY($lw+90,$lh);
		$this->MultiCell(50,6,'www.munipuentepiedra.gob.pe',1,'C');
		$this->SetXY($lw+140,$lh);
		$this->MultiCell(60,6,'Telefono 219 6200 - 219 6201',1,'C');
		//$this->RoundedRect(-10, 0, 220, 8, 1,'S');
		$this->Image('../img/marca/munipuentepiedra.png',$lw,$ln-3,52,15,'PNG');
		
		//$this->SetFillColor(145,185,154); //verde agua
		$this->SetFillColor(255);
		$lh = $lh+6;
		$this->SetXY($lw+70,$lh);
		$this->Cell(160,12,"",0,1,'L',true);
		$this->SetFont('arial','B',12);
		$this->SetXY($lw+35,$lh);
		$this->MultiCell(160,10,$tituloHR1,0,'C');
                /*$this->SetXY($lw+65,$lh+4);
		$this->MultiCell(100,10,$tituloHR2,0,'C');*/
                $this->SetXY($lw+35,$lh+4);
                $this->SetFont('narrow','',8);
		$this->MultiCell(160,10,$tituloHR3,0,'C');
                $this->SetXY($lw+35,$lh+8);
                $this->SetFont('arial','B',12);
		$this->MultiCell(160,10,$tituloHR4,0,'C');
		
                $this->SetXY($lw+150,$lh);
                $this->SetFont('arial','B',20);
		$this->MultiCell(60,10,'HI',0,'C');
                $this->SetXY($lw+150,$lh+4);
                $this->SetFont('arial','B',6);
		$this->MultiCell(60,10,'(Hoja Indice)',0,'C');
                $this->SetXY($lw+150,$lh+7);
                $this->SetFont('arial','B',11);
		$this->MultiCell(60,10,$p_nroDoc,0,'C');
		
                
		//definimos  ancho y color de rectangulo
		$lh = $lh+17;
		
		$nombreContrib1=utf8_decode($nombreContrib);
		$this->SetLineWidth(0.3);
		$this->SetFillColor(255);
		$this->RoundedRect($lw-5, $lh, 110, 24, 1, '');
		
                if(strlen(trim($nombreContrib1))>45 and strlen(trim($nombreContrib1))<=60){
                   $this->SetFont('narrow','',10); 
                }elseif(strlen(trim($nombreContrib1))>60 and strlen(trim($nombreContrib1))<=90 ){
                    $this->SetFont('narrow','',8);
                    
                }elseif(strlen(trim($nombreContrib1))>90){
                    $this->SetFont('narrow','',6);
                    
                }else{
                    $this->SetFont('narrow','',12); 
                }
                
		$this->SetXY($lw-5,$lh+2);
		$this->MultiCell(110,3,trim($nombreContrib1),0,'L');
		$this->SetFont('narrow','',8);
		$this->SetXY($lw-5,$lh+10);
		$this->MultiCell(110,4,trim(utf8_decode($documento)),0,'L');
                $this->SetXY($lw-5,$lh+14);
                 $this->SetFont('narrow','',8);
		$this->MultiCell(110,4,trim(utf8_decode($direccionContrib.' - '.$disdirfiscal)),0,'L');
                $this->SetFont('narrow','',7);
		$this->SetXY($lw-5,$lh+19);
		$this->MultiCell(110,4,trim(utf8_decode($direcreferencia)),0,'L');
                
		
		//$qrcode = new QRcode(utf8_encode('Hola'), $err);
		//$qrcode->disableBorder();
		
		//aqui va el codigo de barras
		//$qrcode->displayHTML();
		//$this->SetXY($lw+10,$lh+12);
		//$qrcode->displayPNG(50);
		//$this->Image(,$lw,$ln,62,18,'PNG');
		
		//$this->SetXY($lw,$lh + 17 );
		//$this->Image('../img/marca/barraBoucher_2dat.gif',$lw-3,$lh+6,13,13,'GIF','');
		
		
                //$this->RoundedRect($lw+110, $lh, 85, 20, 1, '');
		$this->SetFont('arial','B',8);
		$this->SetXY($lw+110,$lh);
		$this->Cell(42,4,"",1,1,'L',true);
		$this->SetXY($lw+112,$lh);
		$this->MultiCell(40,4,'Codigo Contribuyente',0,'J');
		$this->SetXY($lw+152,$lh);
		$this->Cell(43,4,"",1,1,'L',true);
		$this->SetXY($lw+152,$lh);
		$this->SetFont('f25bankprinter','',10);
		$this->MultiCell(43,4,$codigoContrib,0,'R');
		
		$this->SetFont('arial','',8);
		$this->SetXY($lw+110,$lh+4);
		$this->Cell(42,4,"",1,1,'L',true);
		$this->SetXY($lw+112,$lh+4);
		$this->MultiCell(40,4,'Fecha Registro',0,'J');
		$this->SetXY($lw+152,$lh+4);
		$this->Cell(43,4,"",1,1,'L',true);
		$this->SetXY($lw+152,$lh+4);
		$this->SetFont('f25bankprinter','',10);
		$this->MultiCell(43,4,$fechareg,0,'R');
		
		
		$this->SetFont('arial','',8);
		$this->SetXY($lw+110,$lh+8);
		$this->Cell(42,4,"",1,1,'L',true);
		$this->SetXY($lw+112,$lh+8);
		$this->MultiCell(40,4,'Usuario Registro',0,'J');
		$this->SetXY($lw+152,$lh+8);
		$this->Cell(43,4,"",1,1,'L',true);
		$this->SetXY($lw+152,$lh+8);
		$this->SetFont('f25bankprinter','',10);
		$this->MultiCell(43,4,$vusuario,0,'R');
                
                $this->SetFont('arial','',8);
		$this->SetXY($lw+110,$lh+12);
		$this->Cell(42,4,"",1,1,'L',true);
		$this->SetXY($lw+112,$lh+12);
		$this->MultiCell(40,4,'Usuario Impresion',0,'J');
		$this->SetXY($lw+152,$lh+12);
		$this->Cell(43,4,"",1,1,'L',true);
		$this->SetXY($lw+152,$lh+12);
		$this->SetFont('f25bankprinter','',10);
		$this->MultiCell(43,4,$usuario,0,'R');
		
		$this->SetFont('arial','',8);
		$this->SetXY($lw+110,$lh+16);
		$this->Cell(42,4,"",1,1,'L',true);
		$this->SetXY($lw+112,$lh+16);
		$this->MultiCell(40,4,'Fecha Impresion',0,'J');
		$this->SetXY($lw+152,$lh+16);
		$this->Cell(43,4,"",1,1,'L',true);
		$this->SetXY($lw+152,$lh+16);
		$this->SetFont('f25bankprinter','',8);
		$this->MultiCell(43,4,$fechaImpresion,0,'R');
		
		
                $this->SetFillColor(188,217,190); //verde agua
		$ls=-5;
                $lh = $lh +30;
		$this->SetFont('narrow','',8);
		$this->SetXY($lw+$ls,$lh);
		$this->Cell($colCab[0],4,"",1,1,'L',true);
		$this->SetXY($lw+$ls,$lh);
		$this->MultiCell($colCab[0],4,'FORMULARIO',1,'C');
		
		
		$ls = $colCab[0]-5;
		$this->SetFont('narrow','',8);
		$this->SetXY($lw+$ls,$lh);
		$this->Cell($colCab[1]+$colCab[3],4,"",1,1,'L',true);
		$this->SetXY($lw+$ls,$lh);
		$this->MultiCell($colCab[1]+$colCab[3],4,'DESCRIPCION',1,'C');

		$ls = $colCab[0]+$colCab[1]+$colCab[3]-5;
		$this->SetFont('narrow','',8);
		$this->SetXY($lw+$ls,$lh);
		$this->Cell($colCab[2],4,"",1,1,'L',true);
		$this->SetXY($lw+$ls,$lh);
		$this->MultiCell($colCab[2],4,'NRO',1,'C');
	
		
	
		
				
		
	}
	
	function Footer(){
		
	}
	
	function WriteResumen($x,$h1, $corte,$topmar){
		//datos SQL
		global $Coneccion;
                global $lp;

		//datos DOC
		global $marini;
		global $topmar;
		global $repositorioFirmas;
		
                
		
	}
	
	function CheckPageBreak($h){
		if($h >= 105){
			$this->AddPage();	
			return 1;
		}else{
			$this->SetY($h);
			return 0;
		}
		/*if($h >= 250){
			$this->AddPage('P','mm','A4');
			return true;
		}*/
	}
	
	
}


$usuario = $_GET['usuario'];
$contrib =  $_GET['p_mperson'];
$p_mhresum =  $_GET['p_mhresum'];
$predio =  $_GET['p_ccodpre'];

$nro_contrib = $_GET['p_mperson'];
$p_cperiod2 = $_GET['p_cperiod'];
//$p_cperiod = '2014';

$pdf = new PDF('L','mm','A5');
$pdf->SetDisplayMode('fullpage');

if($p_cperiod2=='-1'){
    $Rs_grabarPeriodo = new TSPResult($ConeccionRatania,"");
    $Rs_grabarPeriodo->Poner_MSQL("
        Select t2.cperiod
        from registro.mhresum as t1,
        registro.dresumn as t2
        WHERE t1.idsigma=t2.mhresum
        AND t1.idsigma='".$p_mhresum."'
        group by cperiod 
        order by cperiod desc


        ");
    $Rs_grabarPeriodo->pg_Poner_Esquema("tesoreria");

    $Rs_grabarPeriodo->executeMSQL();
    //echo "<br><br>CONSULTA REQ UPDATE <br> ".$Rs_grabarPeriodo->Escribir_Consulta();
  
    $NPer = 0;
    $NumRowsPer = $Rs_grabarPeriodo->pg_Num_Rows();

    //$p_cperiod=$rowCAB['cperini'];
    //echo $numRowsCAB;
    while($NPer < $NumRowsPer){
        $rowPeriodo= $Rs_grabarPeriodo->pg_Get_Row();

        $periodos[$NPer]=$rowPeriodo['cperiod'];
        $NPer++;
        $Rs_grabarPeriodo->pg_Move_Next();
    }


}else{
    $periodos = explode('-',$p_cperiod2);  
}
//var_dump($periodos);
$periodos= array_unique($periodos);
$p_cperiod = "";
$NPeriodos = count($periodos);

//echo $NPeriodos;
//echo "PERIODOS ".$NPeriodos." PERIDDITO ".  var_dump($periodos);
//die();
$p_cperiod3 = '';
for($j=0; $j<$NPeriodos; $j++){
    /*if($j==($NPeriodos-1)){
        $p_cperiod3 = $p_cperiod3."'".$periodos[$j]."'";
    }else{
        $p_cperiod3 = $p_cperiod3."'".$periodos[$j]."'".',';
    }
    */        
$p_cperiod3 = $periodos[$j];

$filtroConsulta = "";
$filtroConsulta2 = "";
if($p_mhresum<>'-1'){
    $filtroConsulta = " AND t1.idsigma='".$p_mhresum."'";   
}

    


$Rs_grabarCAB = new TSPResult($ConeccionRatania,"");
$Rs_grabarCAB->Poner_MSQL("select t1.idsigma as mhresum_actual, 
    case when public.listas_adicional_per(t2.idsigma) is null
     then '' else public.listas_adicional_per(t2.idsigma) end vadicon,
t1.ctipdat as tipo, 
( select  public.mconten.vdescri from public.mconten WHERE idsigma=t1.cmotivo) as motivo, 
t1.vnrodoc as dj,
(t2.vpatern||' '||t2.vmatern||' '||t2.vnombre) as nombrecontrib,
(t2.cdenomi||' '||t2.vdirecc||' '||t2.vnumero||' '||t2.vmanzan||' '||t2.vlote) dirfiscal,
t2.vreferen as refdirfiscal,
(select vnombres from registro.mubigeo WHERE idsigma=t2.mubigeo) as disdirfiscal,
( COALESCE((select public.mconten.vdescri from public.mconten WHERE idsigma=t2.ctipdoc),' DNI ') )||' '||COALESCE(t2.vnrodoc,'') as documento,
t2.idsigma as cidpers,
(COALESCE((select u.usuario from seguridad.usuario as u  where u.cidusuario=t1.vusernm),t1.vusernm) ) as vusuario,
t1.ddatetm as fechareg,
t1.cperini
from registro.mhresum as t1,
public.mperson as t2
where 
t1.mperson=t2.idsigma
AND t1.mperson='".$nro_contrib."'
$filtroConsulta

");
$Rs_grabarCAB->pg_Poner_Esquema("tesoreria");

$Rs_grabarCAB->executeMSQL();


//echo "<br><br>CONSULTA REQ UPDATE <br> ".$Rs_grabarCAB->Escribir_Consulta();

$NCAB = 0;
$numRowsCAB = $Rs_grabarCAB->pg_Num_Rows();
$rowCAB= $Rs_grabarCAB->pg_Get_Row();
//$p_cperiod=$rowCAB['cperini'];
//echo $numRowsCAB;
while($NCAB < $numRowsCAB){

    
//echo "HOLAAAAAAAAAAAAAAAA";
//echo "<br><br>CONSULTA REQ UPDATE <br> ".$Rs_grabar->Escribir_Consulta();			
$rowCAB= $Rs_grabarCAB->pg_Get_Row();


$RUC='20131366702';
$numero_recibo='860100100014';
$codigoContrib=$rowCAB['cidpers'];
$mhresum_actual=$rowCAB['mhresum_actual'];
$nombreContrib=   $rowCAB['nombrecontrib'].$rowCAB['vadicon'];
$direccionContrib=$rowCAB['dirfiscal'];
$direcreferencia=$rowCAB['refdirfiscal'];
$disdirfiscal=$rowCAB['disdirfiscal'];
$documento=$rowCAB['documento']; 
$vusuario=$rowCAB['vusuario']; 
$fechareg=$rowCAB['fechareg']; 
$c_motivo = $rowCAB['motivo'];
$c_nrodj = $rowCAB['dj'];
$p_cperiod = $p_cperiod3;


$TipoCabecera='1';
//$cajero='NDIESTRO';
//$usuario='NDIESTRO';
//$fechaEmision='12-12-2013 15:56';

//echo 'HOLA '.$fechaProyectado ;
//echo 'USUARIO '.$usuario ;
/*for($i=0; $i<$NPeriodos; $i++){
    $p_cperiod = $periodos[$i];
*/

$tituloHR1 = "DECLARACION JURADA IMPUESTO PREDIAL ".$p_cperiod;
$tituloHR2 = "IMPUESTO PREDIAL ".$p_cperiod;
$tituloHR3 = "Decreto Legislativo 776 Hoja de Actualizacion de Valores";
$tituloHR4 = "MOTIVO ".$c_motivo;
$p_nroDoc = "2014001452";
$p_nroDoc = "Nro ".$c_nrodj;
//$cajero='NDIESTRO';
//$usuario='NDIESTRO';
//$fechaEmision='12-12-2013 15:56';

//echo 'HOLA '.$fechaProyectado ;
//echo 'USUARIO '.$usuario ;






date_default_timezone_set('America/Lima');
$fechaImpresion=strftime('%d/%m/%Y %H:%M:%S'); 
//$nroDoc='42215638';
//$fechaProyectado = '13/12/2013';
//$fechaRecargos = '13/12/2013';
if (!in_array($err, array('L', 'M', 'Q', 'H'))) $err = 'Q';

$colCab = array('22','144','14','20','220');
$colSubCab[0] = array('35','8','18');
$colSubCab[1] = array('18','20','25');
$colSubCab[2] = array('18','8','25');

$topIni = 10;
$marIni = 10; 
$topmar = 32;
$lp = 96;
//$lw=10;


//$pdf->AutoPrint();

$pdf->AliasNbPages();
$p_cperiodPie = $p_cperiod3;

$pdf->AddPage();


//$pdf->SetBottonMargin(140);
$pdf->SetFont('Arial','B',16);

$lw = $marIni;
$var1 = $topmar;
//$var1 = $topmar+5;
$pdf->SetXY($lw,$lh = $var1);


        $pdf->SetFillColor(188,217,190); //verde agua
        $ls=-5;
        $lh = $lh +25;
        $pdf->SetFont('f25bankprinter','',24);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[0],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[0],8,'HR',1,'L');

        $pdf->SetFillColor(255,255,255); //verde agua
        $ls = $colCab[0]-5;
        $pdf->SetFont('f25bankprinter','',14);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[1]+$colCab[3],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[1]+$colCab[3],8,'HOJA DE RESUMEN',1,'C');

        $pdf->SetFillColor(188,217,190); //verde agua
        $ls = $colCab[0]+$colCab[1]+$colCab[3]-5;
        $pdf->SetFont('f25bankprinter','',27);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[2],12,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls-10,$lh);
        $pdf->MultiCell($colCab[2],12,'2',0,'L');
        
         $ls=-5;
         $pdf->SetFillColor(255,255,255); //verde agua
        $pdf->SetFont('narrow','',10);
        $pdf->SetXY($lw+$ls,$lh+8);
        $pdf->Cell($colCab[0]+$colCab[1]+$colCab[3],4,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh+8);
        $texto = 'Indica los datos Personales y el Domicilio Fiscal del Contribuyente';
        $texto = $texto.' Asi como la relación de sus predios y el impuesto predial anual';
        $pdf->MultiCell($colCab[0]+$colCab[1]+$colCab[3],4,  utf8_decode($texto) ,1,'J');
        
        $ls=-5;
        $lh = $lh +12;
        $pdf->SetFillColor(188,217,190); //verde agua
        $pdf->SetFont('f25bankprinter','',24);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[0],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[0],8,'PU',1,'L');

        $pdf->SetFillColor(255,255,255); //verde agua
        $ls = $colCab[0]-5;
        $pdf->SetFont('f25bankprinter','',14);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[1]+$colCab[3],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[1]+$colCab[3],8,'PREDIO URBANO',1,'C');

        $pdf->SetFillColor(188,217,190); //verde agua
        $ls = $colCab[0]+$colCab[1]+$colCab[3]-5;
        $pdf->SetFont('f25bankprinter','',27);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[2],12,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls-10,$lh);
        $pdf->MultiCell($colCab[2],12,'3',0,'L');
        
         $ls=-5;
         $pdf->SetFillColor(255,255,255); //verde agua
        $pdf->SetFont('narrow','',10);
        $pdf->SetXY($lw+$ls,$lh+8);
        $pdf->Cell($colCab[0]+$colCab[1]+$colCab[3],4,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh+8);
        $texto = 'Muestra las características del predio que se determinan su autoavaluo';
        $texto = $texto.' , se emite uno por cada predio';
        $pdf->MultiCell($colCab[0]+$colCab[1]+$colCab[3],4,  utf8_decode($texto) ,1,'J');
        
        $ls=-5;
        $lh = $lh +12;
        $pdf->SetFillColor(188,217,190); //verde agua
        $pdf->SetFont('f25bankprinter','',24);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[0],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[0],8,'HLP',1,'L');

        $pdf->SetFillColor(255,255,255); //verde agua
        $ls = $colCab[0]-5;
        $pdf->SetFont('f25bankprinter','',14);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[1]+$colCab[3],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $texto='Hoja de Liquidación del Impuesto Predial '.$p_cperiod;
        $pdf->MultiCell($colCab[1]+$colCab[3],8,utf8_decode($texto),1,'C');

        $pdf->SetFillColor(188,217,190); //verde agua
        $ls = $colCab[0]+$colCab[1]+$colCab[3]-5;
        $pdf->SetFont('f25bankprinter','',27);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[2],12,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls-10,$lh);
        $pdf->MultiCell($colCab[2],12,'4',0,'L');
        
         $ls=-5;
         $pdf->SetFillColor(255,255,255); //verde agua
        $pdf->SetFont('narrow','',10);
        $pdf->SetXY($lw+$ls,$lh+8);
        $pdf->Cell($colCab[0]+$colCab[1]+$colCab[3],4,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh+8);
        $texto = 'Informa acerca de la forma de calculo del impuesto predial.';
        $texto = $texto.' .Contiene los montos a cancelar en cualquiera de nuestras agencias de Pago';
        $pdf->MultiCell($colCab[0]+$colCab[1]+$colCab[3],4,  utf8_decode($texto) ,1,'J');
        
        $ls=-5;
        $lh = $lh +12;
        $pdf->SetFillColor(188,217,190); //verde agua
        $pdf->SetFont('f25bankprinter','',24);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[0],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->MultiCell($colCab[0],8,'HLA',1,'L');

        $pdf->SetFillColor(255,255,255); //verde agua
        $ls = $colCab[0]-5;
        $pdf->SetFont('f25bankprinter','',14);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[1]+$colCab[3],8,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh);
        $texto='Hoja de Liquidación Arbitrios '.$p_cperiod;
        $pdf->MultiCell($colCab[1]+$colCab[3],8,utf8_decode($texto),1,'C');

        $pdf->SetFillColor(188,217,190); //verde agua
        $ls = $colCab[0]+$colCab[1]+$colCab[3]-5;
        $pdf->SetFont('f25bankprinter','',27);
        $pdf->SetXY($lw+$ls,$lh);
        $pdf->Cell($colCab[2],12,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls-10,$lh);
        $pdf->MultiCell($colCab[2],12,'5',0,'L');
        
         $ls=-5;
         $pdf->SetFillColor(255,255,255); //verde agua
        $pdf->SetFont('narrow','',10);
        $pdf->SetXY($lw+$ls,$lh+8);
        $pdf->Cell($colCab[0]+$colCab[1]+$colCab[3],4,"",1,1,'L',true);
        $pdf->SetXY($lw+$ls,$lh+8);
        $texto = 'Informa acerca de la forma de calculo de los arbitrios.';
        $texto = $texto.' .Contiene los montos a cancelar en cualquiera de nuestras agencias de Pago';
        $pdf->MultiCell($colCab[0]+$colCab[1]+$colCab[3],4,  utf8_decode($texto) ,1,'J');
        

	


        $Rs_grabarCAB->pg_Move_Next();
	$NCAB++;
}

}//DIN DE ARRAY PERIODOS NUEVO
		
$lw=$marIni;		
//$var1 = $pdf->GetY();				
//$pdf->WriteResumen($lw,$var1, $corte,$topmar);
$pdf->Output();


?>